package com.matt.foundation.utils;

import lombok.Data;
import org.apache.commons.lang.RandomStringUtils;

import java.util.Random;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/6/5
 * *******************************
 */
@Data
public class OrderNoUtil {

    public static final String D_PREFIX = "D";
    public static final String S_PREFIX = "S";


    public static String distributorOrder(Long distributorId){
        return D_PREFIX + distributorId + System.currentTimeMillis() + randomStr();
    }


    public static String supplierOrder(Long supplierId){
        return S_PREFIX + supplierId + System.currentTimeMillis() + randomStr();
    }


    private static String randomStr(){
        Random random = new Random();
        Integer num = random.nextInt(1000);
        if (num<100)
            return "00" +num;
        if (num<10)
            return "000"+num;
        else
            return "0" + num;
    }

}
